package com.github.cyf.databaseLock;

import com.github.cyf.databaseLock.impl.MysqlLock;
import com.github.cyf.databaseLock.impl.RedisLock;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * @author chenyifan
 * @create 2024-07-11 17:36
 */
@Configuration
public class LockConfig {

    @Bean("mysqlLock")
    public ILock mysqlLock(ThreadPoolTaskScheduler taskScheduler, JdbcTemplate jdbcTemplate) {
        return new MysqlLock(taskScheduler, jdbcTemplate);
    }

    @Bean("redisLock")
    public ILock redisLock(ThreadPoolTaskScheduler taskScheduler, RedisTemplate redisTemplate) {
        return new RedisLock(taskScheduler, redisTemplate);
    }
}